// 路由器
import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
import Search from "@/pages/Search";
import Home from "@/pages/Home";
import Register from "@/pages/Register";
import Login from "@/pages/Login";
const originPush=VueRouter.prototype.push
VueRouter.prototype.push=function(location,resolve,reject){
    // console.log(this.originPush);//undefined
    if(resolve&&reject){
        originPush.call(this,location,resolve,reject)
    }else{
        originPush.call(this,location,res=>{
            console.log(res);
        },err=>{
            console.log(err);
        })
    }
}

const router = new VueRouter({
  routes: [
    {
      path: "/home",
      component: Home,
      meta: { showFooter: true },
    },
    {
      name: "search",
      path: "/search/:searchMsg?",
      component: Search,
      meta: { showFooter: true },
      props(r) {
        return { a: r.query.a, msg: r.params.msg };
      },
    },
    {
      path: "/register",
      component: Register,
      meta: { showFooter: false },
    },
    {
      path: "/login",
      component: Login,
      meta: { showFooter: false },
    },
    {
      path: "*",
      redirect: "/home",
    },
  ],
});
export default router;
